import { request } from '@/service/index'


export const addDiary = (params: API.DIARY) => {
  return request<string>({
    url: `/dailyNote/api/diary/addDiary`,
    method: 'POST',
    params
  })
}


// 回复日志
export const addDiaryMessage = (params: API.MESSAGE) => {
  return request<string>({
    url: `/dailyNote/api/diary/addDiaryMessage`,
    method: 'POST',
    params
  })
}


// 回复留言
export const addReplyDiaryMessage = (params: API.MESSAGE) => {
  return request<string>({
    url: `/dailyNote/api/diary/replyDiaryMessage`,
    method: 'POST',
    params
  })
}

export const getDiaryPage = (params: API.DIARYPAGE) => {
  return request<API.ResponsePage<API.DIARY[]>>({
    url: `/dailyNote/api/diary/getDiary`,
    method: 'POST',
    params
  })
}

// 根据日志id获取评论
export const getDiaryMessageByDiaryId = (diaryId: string, page: number,pageSize: number) => {
  return request<API.ResponsePage<API.MESSAGE[]>>({
    url: `/dailyNote/api/diary/getDiaryMessage/${diaryId}/${page}/${pageSize}`,
    method: 'GET',
  })
}

// 根据日志id获取评论
export const getDiaryByDiaryId = (diaryId: string) => {
  return request<API.DIARY>({
    url: `/dailyNote/api/diary/getDiaryById/${diaryId}`,
    method: 'GET',
  })
}

// 根据一级评论id获取二级评论
export const getLevel2MessgaeByMessageId = (messageId: string, page: number) => {
  return request<API.ResponsePage<API.MESSAGE[]>>({
    url: `/dailyNote/api/diary/getDiaryMessageMore/${messageId}/${page}`,
    method: 'GET',
  })
}

export const getMyDiaryPage = (page: number) => {
  return request<API.ResponsePage<API.DIARY[]>>({
    url: `/dailyNote/api/diary/getMyDiary/${page}`,
    method: 'GET',
  })
}

export const opraDiaryLikeStatus = (diaryId: string, status: 0 | 1) => {
  const cancelUrl = `/dailyNote/api/diary/cancelLike/${diaryId}`
  const likeUrl = `/dailyNote/api/diary/like/${diaryId}`
  return request<API.DIARY[]>({ 
    url: status ? likeUrl : cancelUrl,
    method: 'POST',
  })
}

// 
export const getDiaryEmoji = () => {
  return request<{title: string, options: API.EMOJI[]}[]>({
    url: `/dailyNote/api/diary/getDiaryEmoji`,
    method: 'GET',
  })
}


export const getDiaryByRiZhu = (params: API.RIZHU) => {
  return request<API.DIARY[]>({
    url: `/dailyNote/api/diary/getDiaryByRiZhu`,
    method: 'POST',
    params
  })
}



export const getTGZRPage = (time: string, page: number) => {
  return request<API.ResponsePage<API.DIARY[]>>({
    url: `/dailyNote/api/diary/getMyDiary/${time}/${page}`,
    method: 'GET'
  })
}



// 根据时干获取日志
export const getDiaryByHourGanWithDay = (hourGan: string, day: string, page: number) => {
  return request<API.ResponsePage<API.DIARY[]>>({
    url: `/dailyNote/api/diary/getDiaryByHourGanWithDay/${hourGan}/${day}/${page}`,
    method: 'GET'
  })
}

